<template>
  <div>
    <a-card :bordered="false">
      <f-search-form @searchHandler="searchHandler">
        <f-search-form-item label="单号" name="orderNo"/>
      </f-search-form>
      <f-table ref="table" size="default" rowKey="couponId" :columns="columns" :multiple="false" :operator="operator" :params="queryParam" :api="api.settle.totalSaleByShop">
        <span slot="action" slot-scope="text, record">
          <template>
            <a @click="$refs.modal.handleShow(record)">明细</a>
            <a-divider type="vertical"/>
          </template>
          <a-dropdown>
            <a class="ant-dropdown-link">
              更多 <a-icon type="down"/>
            </a>
            <a-menu slot="overlay">
              <a-menu-item v-if="$auth('table.delete')">
                <a href="javascript:;" @click="$refs.table.remove(record.couponId)">导出</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </f-table>
    </a-card>
  </div>
</template>
<script>
  export default {
    name: 'OrderInfo',
    components: {},
    props: {
      shopId: {
        type: String,
        default: ''
      }
    },
    data() {
      let me = this
      return {
        //列表初始化查询参数
        queryParam: {
          shopId: this.shopId
        },
        // 表头
        columns: [
          {
            title: '单号',
            dataIndex: 'orderNo'
          },
          {
            title: '订单金额',
            dataIndex: 'totalAmount',
            align: 'center'
          },
          {
            title: '运费',
            dataIndex: 'freightAmount',
            align: 'center'
          },
          {
            title: '优惠券金额',
            align: 'center',
            dataIndex: 'couponAmount'
          },
          {
            title: '折扣金额',
            dataIndex: 'discountAmount',
            align: 'center'
          },
          {
            title: '付款金额',
            dataIndex: 'payAmount',
            align: 'center'
          },
          {
            title: '买家姓名',
            dataIndex: 'userName'
          },
          {
            title: '付款日期',
            dataIndex: 'payTime'
          }
        ],
        //操作按钮
        operator: []
      }
    },
    created() {

    },
    methods: {
      searchHandler(params) {
        this.$refs.table.refresh(true, params)
      },
      setState(check, record) {
        this.http.post(this, {
          url: this.api.coupon.update,
          data: {
            id: record.couponId,
            state: Number(check)
          },
          success(me, data) {
            console.log(data)
            record.state = data.state
          }
        })
      }
    }

  }
</script>
